import {createRouter, createWebHistory} from 'vue-router'
import Layout from "@/layout/index";
import product from "./module/product";
import homeManage from "./module/homeManage";
import authority from "@/router/module/authority";
import channel from "@/router/module/channel";
import order from "@/router/module/order";
import user from "@/router/module/user";
import institution from "@/router/module/institution";
import system from "@/router/module/system";
import report from "@/router/module/report";
import market from "@/router/module/market";
import loanSupermarket from "@/router/module/loanSupermarket";
/**
 * isHideSidebar 是否不显示侧边栏
 * title 路由名称
 * isDetailsPage 是否详情页 添加该字段不经过后台权限过滤
 */
export const constantRoutes = [
    {
        path: '/login',
        name: 'login',
        component: () => import('@/components/Login/index'),
    }
]
// 动态加载路由页
export const asyncRoutes = [
    {
        path: '/',
        component: Layout,
        redirect: '/index',
        meta: {
            title: '首页',
        },
        children: [
            {
                path: 'index',
                name: 'Index',
                meta: {
                    title: '首页',
                    icon: 'home-4-line',
                },
                component: () => import('@/views/home/index'),
            }
        ],

    },
    product,
    homeManage,
    authority,
    channel,
    order,
    user,
    institution,
    system,
    report,
    market,
    loanSupermarket,
]
const routerHistory = createWebHistory()
const router = createRouter({
    scrollBehavior() {
        // 始终滚动到顶部
        return {top: 0}
    },
    history: routerHistory,
    routes: constantRoutes
})
export default router
